package com.czz.manage.controller.teacher;

import com.czz.common.exception.ResultCodeEnum;
import com.czz.common.vo.R;
import com.czz.manage.service.DashBoardService;
import com.czz.manage.vo.DashBoardVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName: DashBoardTeacherController
 * @Author Czz
 * @Date 2020/2/19
 * @Time 10:17
 **/
@RestController
@RequestMapping(value = "/teacher/dashboard")
public class DashBoardTeacherController {

    @Autowired
    DashBoardService dashBoardService;

    /**
    * @Description 讲师首页信息
    * @Param []
    * @Return com.czz.common.vo.R
    * @Author Czz
    * @Date 2020/2/19
    * @Time 10:21
    **/
    @GetMapping(value = "{id}")
    public R getTeacherDashBoardData(@PathVariable String id){
        if (StringUtils.isEmpty(id)){
            return R.setResult(ResultCodeEnum.INPUT_ERROR);
        }
        DashBoardVo dashBoardVo = dashBoardService.getTeacherDashBoardData(id);
        return R.ok().data("item",dashBoardVo);
    }

    /**
    * @Description 获取echarts数据
    * @Param []
    * @Return com.czz.common.vo.R
    * @Author Czz
    * @Date 2020/2/19
    * @Time 10:56
    **/
    @GetMapping(value = "chart/{id}")
    public R getTeacherChartData(@PathVariable String id){
        if (StringUtils.isEmpty(id)){
            return R.setResult(ResultCodeEnum.INPUT_ERROR);
        }
        Map<String,Object> map = dashBoardService.getTeacherChartData(id);
        return R.ok().data("item",map);
    }
}
